﻿using B.S.Passport.Domain;
using B.S.Passport.ErrorCode;
using B.S.Passport.Infacetrue;
using B.S.Passport.Read.API.Application.Command123;
using DAL;
using MediatR;
using Microsoft.AspNetCore.Mvc.Formatters.Xml;

namespace B.S.Passport.Read.API.Application.Commandhander123
{
    public class GetWHouseTypeCommandHander : IRequestHandler<GetWHouseTypeCommand, ApiResult<List<WHouseType>>>
    {
        public readonly IBaseRepository<List<WHouseType>> baseRepository;
        public readonly DBHelper1 dBHelper;

        public GetWHouseTypeCommandHander(IBaseRepository<List<WHouseType>> baseRepository, DBHelper1 dBHelper)
        {
            this.baseRepository = baseRepository;
            this.dBHelper = dBHelper;
        }
        /// <summary>
        /// 获取库位类型
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<ApiResult<List<WHouseType>>> Handle(GetWHouseTypeCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<WHouseType>> apiResult = new ApiResult<List<WHouseType>>();
            apiResult.Code = (ApiEnums)Renum.显示成功;
            apiResult.Message = Renum.显示成功.ToString();
            var sql = $"select * from WHouseType";
            var ss = dBHelper.GetList<WHouseType>(sql).ToList();
            apiResult.Data = ss;
             return Task.FromResult(apiResult);
        }
    }
}
